package demo1;

import java.util.Arrays;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-06-25
 * Time: 19:54
 */
public class Test {
    public static void main(String[] args) {

    }

    public static void mySort(Comparable[] comparable) {
        for (int i = 0; i < comparable.length - 1; i++) {
            for (int j = 0; j < comparable.length - 1 - i; j++) {
                if(comparable[j].compareTo(comparable[j+1]) > 0) {
                    Comparable tmp = comparable[j];
                    comparable[j] = comparable[j+1];
                    comparable[j+1] = tmp;
                }
            }
        }
    
    }

    public static void main3(String[] args) {
        
        Student student1 = new Student("zhangsan",10);
        Student student2 = new Student("lisi",20);
        Student student3 = new Student("wangwu",30);
        Student[] student = {student2,student1,student3};
        System.out.println("排序前：" + Arrays.toString(student));
        mySort(student);
        System.out.println("排序后: " + Arrays.toString(student));
        
    }
    public static void main2(String[] args) {
        Student student1 = new Student("zhangsan",10);
        Student student2 = new Student("lisi",20);
        Student student3 = new Student("wangwu",30);
        Student[] student = {student2,student1,student3};
        System.out.println("排序前：" + Arrays.toString(student));
        Arrays.sort(student);
        System.out.println("排序后: " + Arrays.toString(student));
    }
    public static void main1(String[] args) {
        Student student1 = new Student("zhangsan",10);
        Student student2 = new Student("lisi",20);
        System.out.println(student1.compareTo(student2));
    }
}
